import http from '@/utils/http'

const BASE_URL = '/jobfair/jobPosition'

export interface JobPositionResp {
  title: string
  salary: string
  location: string
  createUserString: string
  updateUserString: string
}
export interface JobPositionDetailResp {
  id: string
  companyId: string
  jobFairId: string
  title: string
  description: string
  requirements: string
  salary: string
  location: string
  createTime: string
  updateTime: string
  createUser: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface JobPositionQuery {
  companyId: string
  jobFairId: string
  title: string
  salary: string
  location: string
  sort: Array<string>
}
export interface JobPositionPageQuery extends JobPositionQuery, PageQuery {}

/** @desc 查询双选会企业岗位列表 */
export function listJobPosition(query: JobPositionPageQuery) {
  return http.get<PageRes<JobPositionResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询双选会企业岗位详情 */
export function getJobPosition(id: string) {
  return http.get<JobPositionDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增双选会企业岗位 */
export function addJobPosition(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改双选会企业岗位 */
export function updateJobPosition(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除双选会企业岗位 */
export function deleteJobPosition(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出双选会企业岗位 */
export function exportJobPosition(query: JobPositionQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
